package com.windy.myvideo.widget;

import android.graphics.SurfaceTexture;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.View;

import tv.danmaku.ijk.media.player.IMediaPlayer;

/**
 * Created by dingfeng on 2016/9/12.
 */
public interface IRenderView {

    static final int AR_ASPECT_FIT_PARENT = 0;
    static final int AR_ASPECT_FILL_PARENT = 1;
    static final int AR_ASPECT_WRAP_CONTENT = 2;
    static final int AR_MATCH_PARENT = 3;
    static final int AR_16_9_FIT_PARENT = 4;
    static final int AR_4_3_FIT_PARENT = 5;

    View getView();

    boolean shouldWaitForResize();

    void setVideoSize(int videoWidth, int videoHeight);

    void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen);

    void setVideoRotation(int degree);

    void setAspectRatio(int aspectRatio);

    void addRenderCallback(IRenderCallback callback);

    void removeRenderCallback(IRenderCallback callback);

    public interface IRenderCallback {

        /**
         * @param holder
         * @param width   could be 0
         * @param height  could be 0
         */
        void onSurfaceCreated(ISurfaceHolder holder, int width, int height);

        /**
         * @param holder
         * @param format   could be 0
         * @param width
         * @param height
         */
        void onSurfaceChanged(ISurfaceHolder holder, int format, int width, int height);

        void onSurfaceDestroyed(ISurfaceHolder holder);
    }

    interface ISurfaceHolder {

        void bindToMediaPlayer(IMediaPlayer mp);

        IRenderView getRenderView();

        SurfaceHolder getSurfaceHolder();

        Surface openSurface();

        SurfaceTexture getSurfaceTexture();
    }

}
